#include "app_porting.h"

void start_task(void *pdata)
{
	OS_CPU_SR cpu_sr=0;
	
	pdata=pdata;
	
	app_init();
	
	OS_ENTER_CRITICAL();
	OSTaskCreate(console_task,(void*)0,(OS_STK*)&CONSOLE_TASK_STK[CONSOLE_STK_SIZE-1],CONSOLE_TASK_PRIO);
	OSTaskCreate(invensense_task,(void*)0,(OS_STK*)&INVENSENSE_TASK_STK[INVENSENSE_STK_SIZE-1],INVENSENSE_TASK_PRIO);
	OSTaskCreate(task_fp_process,(void*)0,(OS_STK*)&FP_PROCESS_TASK_STK[FP_PROCESS_STK_SIZE-1],FP_PROCESS_TASK_PRIO);
	OSTaskCreate(task_fp_update,(void*)0,(OS_STK*)&FP_UPDATE_TASK_STK[FP_UPDATE_STK_SIZE-1],FP_UPDATE_TASK_PRIO);
	OSTaskCreate(crack_task,(void*)0,(OS_STK*)&CRACK_TASK_STK[CRACK_STK_SIZE-1],CRACK_TASK_PRIO);
	OS_EXIT_CRITICAL();
	
#ifdef LIB_PRINTF_SUPPORT
	printf("[%s](%d) task created.\r\n",__FUNCTION__,__LINE__);
#endif

	while(1){
		OSTimeDlyHMSM(0,0,0,300);	
		idle_process();
		debug_led_reverse();
	}
}

int main(void)
{
	sys_init();
	OSInit();
	OSTaskCreate(start_task,(void*)0,(OS_STK*)&START_TASK_STK[START_STK_SIZE-1],START_TASK_PRIO); 
	OSStart(); 
}

